package com.isorf.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.isorf.mapper.brandmapper;
import com.isorf.pojo.brand;
import com.isorf.pojo.links;
import com.isorf.service.brandservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class brandserviceimpl implements brandservice {
    @Autowired
    private brandmapper brandmapper;

    @Override
    public Boolean deletebrand(Integer brandid) {
        int result = brandmapper.deletebrand(brandid);
        return result > 0;
    }

    @Override
    public List<brand> getallbrand() {
        return brandmapper.getallbrand();
    }

    @Override
    public Boolean updatebrand(brand brand) {
        int result = brandmapper.updatebrand(brand);
        return result > 0;
    }

    @Override
    public Boolean addbrand(brand brand) {
        int result = brandmapper.addbrand(brand);
        if (result > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public PageInfo<brand> pageList(int pageNum, int pageSize) {

        // 使用PageHelper.startPage方法设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        // 查询所有用户数据，此时查询会被自动分页
        List<brand> userList = (List<brand>) brandmapper.pageList();
        // 使用PageInfo包装查询结果，便于页面使用
        return new PageInfo<>(userList);
    }


    @Override
    public Boolean batchDelete(List<Integer> ids) {
        int result = brandmapper.batchDelete(ids);
        return result > 0;
    }




}
